home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / ans / chap12 / exer1204 / Ex1204a.java next >
Encoding:
Java Source  |  1997-04-20  |  494 b   |  25 lines

  1. class Ex1204a {
  2.    public static void main(String[] args) {
  3.       MyThread t1 = new MyThread(1);
  4.       MyThread t2 = new MyThread(2);
  5.  
  6.       t1.setPriority(Thread.MAX_PRIORITY);
  7.       t2.setPriority(Thread.MIN_PRIORITY);
  8.  
  9.       t1.start();
  10.       t2.start();
  11.    }
  12. }
  13.  
  14. class MyThread extends Thread {
  15.    int id;
  16.    MyThread(int id) {
  17.       this.id = id;
  18.    }
  19.  
  20.    public void run() {
  21.       for (int i = 0; i < 100; i++)
  22.          System.out.println("My id is " + id);
  23.    }
  24. }
  25.